package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Attendance;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class AttendanceVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "打卡状态：0未打卡 1正常 2请假 3异常")
    private Integer attendanceType;

    @ApiModelProperty(value = "配置id")
    private Integer arrangeId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "公司id")
    private Integer companyId;

    @ApiModelProperty(value = "请假时长（小时）")
    private String leaveDuration;

    @ApiModelProperty(value = "打卡地址")
    private String address;

    @ApiModelProperty(value = "外勤打卡标识： 0否 1是")
    private Integer isField;

    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Attendance convert(AttendanceVO vo) {
        Attendance entity = new Attendance();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Attendance> convertList(List<AttendanceVO> list) {
        List<Attendance> resultList = new ArrayList<>();
        for (AttendanceVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
